<!DOCTYPE html>
<html>
<head>
    <title>region form</title>
    <#include "/header.html">
</head>
<body class="bg-white">
<div id="appMain">
    <form class="layui-form layuimini-form" action="" lay-filter="dataForm">
        <div class="layui-form-item">
            <label class="layui-form-label">区划代码</label>
            <div class="layui-input-block">
                <input type="text" name="id" value="" class="layui-input layui-disabled" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">地区名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" value="" class="layui-input layui-disabled" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">行政等级</label>
            <div class="layui-input-block">
                <select name="grade" disabled>
                    <option value="1">省</option>
                    <option value="2">市</option>
                    <option value="3">区</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">地区类型</label>
            <div class="layui-input-block">
                <input type="radio" name="type" value="0" title="经济区">
                <input type="radio" name="type" value="1" title="偏远地区">
                <input type="radio" name="type" value="2" title="港澳台">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">纬度</label>
            <div class="layui-input-block">
                <input type="text" name="latitude" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">经度</label>
            <div class="layui-input-block">
                <input type="text" name="longitude" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" id="commitBtn" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form,
            $ = layui.$;

        $(document).ready(function () {
            if (parent.formDataId > 0) {
                $.ajax({
                    type: "POST",
                    url: serverUrl('region/info/' + parent.formDataId),
                    data: {},
                    dataType: "json",
                    success: function (result) {
                        if (result.code === 0) {
                            form.val('dataForm', result.info);
                        }
                    }
                });
            }
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            /*alert(JSON.stringify(data.field));
            return false;*/
            var params = data.field;
            submitFormData('region/update', params);

            return false;
        });

    });
</script>
</body>
</html>